package kr.hkit.powerjava.chapter06.work;

import java.util.Scanner;

public class Lab {

	public static void main(String[] args) {

		double bunja, bunmo, sum;
		int count;
		bunja = 4.0;
		bunmo = 1.0;
		sum = 0.0;

		Scanner in = new Scanner(System.in);

		System.out.print("반복횟수 : ");
		count = in.nextInt();

		while (count > 0) {

			sum = sum + bunja / bunmo;
			bunja = -1.0 * bunja;
			bunmo = bunmo + 2;
			count--;

		}
		System.out.printf("PI = " + sum);

	}

}
